<?php
header("content-type:text/html;charset=utf-8");

$db=new mysqli("localhost","root","root","mogujie");

$sql="SELECT * FROM register";

$result=$db->query($sql);

$arr=[];

while($row=$result->fetch_array(MYSQLI_ASSOC)){
    array_push($arr,$row);
}

$json=json_encode($arr);

echo $json;
?>